package com.yxdj.user.api.factory;

import com.yxdj.common.core.domain.R;
import com.yxdj.user.api.RemoteAddressService;
import com.yxdj.user.api.domain.Address;
import org.springframework.cloud.openfeign.FallbackFactory;

import java.util.List;

/**
 * @author 韩总
 */
public class RemoteAddressFallbackFactory implements FallbackFactory<RemoteAddressService> {
    @Override
    public RemoteAddressService create(Throwable cause) {
        return new RemoteAddressService() {
            @Override
            public R<List<Address>> getUserAddressByUserId(Long userId, String source) {
                return R.fail("远程调用用户微服务根据用户id获取用户所有的地址失败："+cause.getMessage());
            }

            @Override
            public R<Address> getAddressById(Long id, String source) {
                return R.fail("远程调用用户微服务根据地址id获取地址信息失败："+cause.getMessage());
            }
        };
    }
}
